package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 留言反馈表
 *
 * @author education-platform
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("feedback")
@JsonIgnoreProperties(value = {"handler"})
public class Feedback {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 反馈类型
     */
    @TableField("type")
    private String type;

    /**
     * 反馈标题
     */
    @TableField("title")
    private String title;

    /**
     * 反馈内容
     */
    @TableField("content")
    private String content;

    /**
     * 附件图片
     */
    @TableField("images")
    private String images;

    /**
     * 联系方式
     */
    @TableField("contact_info")
    private String contactInfo;

    /**
     * 管理员回复
     */
    @TableField("reply")
    private String reply;

    /**
     * 处理状态
     */
    @TableField("status")
    private String status;

    /**
     * 优先级
     */
    @TableField("priority")
    private String priority;

    /**
     * 回复人ID
     */
    @TableField("replied_by")
    private Long repliedBy;

    /**
     * 回复时间
     */
    @TableField("replied_at")
    private LocalDateTime repliedAt;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private User user;

    @TableField(exist = false)
    private User replier;

    // 枚举定义
    public enum Type {
        BUG("Bug反馈"),
        FEATURE("功能建议"),
        COMPLAINT("投诉举报"),
        OTHER("其他");

        private final String description;

        Type(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum Status {
        PENDING("待处理"),
        PROCESSING("处理中"),
        RESOLVED("已处理"),
        CLOSED("已关闭");

        private final String description;

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum Priority {
        LOW("低"),
        NORMAL("普通"),
        HIGH("高"),
        URGENT("紧急");

        private final String description;

        Priority(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}

